#!/bin/bash
#skript vypisující vlastní procesy

ulohy=`qstat`

naseUlohy=$(echo "$ulohy" | grep `whoami`)
result="Nase aktualne spustene ulohy:"
if [ -n "$naseUlohy" ]
  then
    result="$result"$'\n'"$naseUlohy"
  fi
result="$result"$'\n'

idNasichUloh=`echo "$naseUlohy" | cut --delimiter=' ' -f 3`
result="$result"$'\n'"Pro konkretni informace o uloze spustit:"
for j in ${idNasichUloh[@]}
  do
    result="$result"$'\n'"  qstat -j $j | less"
  done
result="$result"$'\n'

result="$result"$'\n'"Vsechny aktualne spustene ulohy:"
result="$result"$'\n'"$ulohy"

echo "$result" | less
